Check romhacking.net or the Tactics Ogre and Ogre Battle Modding discord for 
info and updates.

Discord invite:
https://discord.gg/YRWaZsQ89p

---

This is a spreadsheet and a set of python scripts that edit all currently known 
item and shop data (minus text) for the SNES version of Ogre Battle - The March 
Of The Black Queen.

It requires Libre Office Calc, an open source spreadsheet editor that is free 
to download and install - though your bandwidth may take a bit of a hit, as 
it's usually a few hundred megabytes to download.

I don't know if it will work with Microsoft Excel, and if it doesn't then don't 
say I didn't warn you.

---

How to edit data and apply your changes to a rom.

0. Back up the spreadsheet and your rom so you have a fresh vanilla version 
   when you screw up.

1. Edit the green-ish portions of of the Shops and Items sheets.
   
   Make sure that all values are 8 bit bytes in hexadecimal (base 16) format. 
   For a primer on the subject, read this:
   
   https://fantasyanime.com/save-state-hacking
   
   If your rom is headered, put a number 1 in cell K4 of the Guts sheet. If 
   it's not, put a number 0 there. For clarification, this is the cell with the 
   green background with the "Header?" note next to it.
   
   If you're not sure if your rom is headered or not, download and run SNES ROM 
   Utility, and open your rom with it. It will tell you if it's headered.
   
   Link to SNES ROM Utility:
   https://www.romhacking.net/utilities/593/
   
   Now you can either get the name of your rom and put it in the big green cell 
   under "Name of ROM" in the sheet Guts, or you can name your rom the same as 
   the text in that cell. I prefer the latter as it's easier to type, but if 
   you have a custom name for your mod then you may disagree. Whatever the 
   case, ensure that the name in that cell is the same as the name of your rom.
   
   Don't edit anything that's not green, especially anything red or yellow, and 
   do not edit the CSV sheet.
   
   The preview areas found in some sheets tell you what your changes will be. 
   You can also reference the Key sheet for information on what each hex number 
   means.

2. When you're done editing, go the "CSV" sheet and use the "Save As" button or 
   the menu option to "Save As".
   
   Once there, select the "Save as type" box, and scroll down to select the 
   "Text CSV (*.csv)" option. Give it any name you want, and I recommend you 
   save it in the same folder as the it's editor, and give it a descriptive 
   name. If this is confusing, just save it and manually rename it afterwards 
   in the file explorer.
   
   There will be several confirmations and maybe a warning, just click OK but 
   don't change any settings otherwise.

3. Put your OB - MOTBQ rom in the same folder as the *.csv file you just 
   created.
   
4. Read the command-prompt-faq.txt file if you haven't already. If you have any 
   experience with Linux, Powershell, the command prompt, or programming then 
   you can probably skip it, or skim it only if you are bored or have problems.
   
   Make sure you have some version of Python 3 installed, the faq mentioned 
   above can help you install it if you don't or don't know what that is.
   
5. Now that you've familiarized yourself with the command prompt, open it up 
   and use the cd and dir commands to navigate to the folder where you put your 
   rom and newly created *.csv file.

6. Enter the following commands:
   
   python .\writeCSV.py .\shops-items-editor.csv
   
   Note that "shops-items-editor.csv" is a stand-in for whatever you named your 
   *.csv file a few minutes ago.
   
7. That's it, you should've applied your changes. Test your rom, double check 
   your edits, and if you still have problems come hassle us in the discord 
   link above. I'll probably make a thread on romhacking.net soon too.

---

How to extract your changes from a rom, and insert them into the editor.

0. Run the following command on the rom that has your changes:
   
   python dumpShopsItems.py .\OB-MOTBQ.sfc 1 > myShopsItems.txt
   
   Note that the "OB-MOTBQ.sfc" is a stand-in for whatever you've named your 
   rom. Also note that you can use tab to autocomplete your rom name if it has 
   a lot of spaces or you're lazy.
   
   Make sure your rom is in the same folder as dumpShopsItems.py
   
   The 1 above indicates that the rom has a header. Use a 0 in it's place if it 
   doesn't.
   
   The text "myShopsItems.txt" is just the name of the text file this script 
   will create. You can name it anything, just make sure you add the ".txt" at 
   the end so it will be recognized as a text file.
   
1. Open myShopsItems.txt (or whatever you called it) with Notepad, or your 
   favorite plain text editor.
   
   You should see neat orderly rows of hexadecimal numbers wrapped in single 
   quotes, each with a title above them.
   
   The title corresponds to the sheet in the encounter-editor.ods spreadsheet.
   
   Highlight each table of numbers, making sure to get all the numbers and 
   their single quotes, but no titles or empty lines.
   
   Copy them, and paste them using the right click menu, paste special, and 
   unformatted text options.
   
   You should see a box pop up called "Text Import". Select "Separated by", and 
   put checks in the "Space", "Merge delimiters", "Trim spaces", and "Format 
   quoted field as text" options.
   
   In the box next to the "String delimiter", selec the single quote option.
   
   The preview below should change as you do this.
   
   Congrats, you imported your changes into a spreadsheet and can now edit them 
   some more.
   
   Note: If you want to view the vanilla encounter data, follow these 
   instructions starting at number 1, using the file "vanillaShopsItems.txt".

---

Hint of the Day: Error messages are very useful, read them and be sure to post 
them on the forums or discord if you get one. Sometimes I make mistakes and 
write the wrong command for you to type too, double check my instructions with 
the files provided to ensure they match.

---

Software Endorsements

This section is mostly unrelated to the task at hand, just shilling my 
preferred applications.

This file is best viewed in a plain text editor such as Notepad, Notepad2, or 
Notepad++. I prefer Notepad2, which is here:
http://www.flos-freeware.ch/notepad2.html

My preferred hex editor is XVI32, which is here:
http://www.chmaas.handshake.de/delphi/freeware/xvi32/xvi32.htm

